package com.gxuwz.check.dao.login.impl;

import com.alibaba.fastjson.JSONObject;
import com.gxuwz.check.base.BaseDao;
import com.gxuwz.check.dao.login.ILoginDao;
import com.gxuwz.check.model.entity.SysUserEntity;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class LoginDaoImpl extends BaseDao implements ILoginDao {
    JSONObject jsonObject = new JSONObject();
    @Override
    public SysUserEntity findUserInfoByUserName(String userName) {
        String hql = "FROM SysUserEntity u where u.userName = ?";
        List list = getHibernateTemplate().find(hql,userName);
        System.out.println("list   "+list);
        if (list.isEmpty()){
            return null;
        }
        return (SysUserEntity) list.get(0);
    }

    @Override
    public SysUserEntity userInfo(String userId){
        String hql = "from SysUserEntity u where u.userId = ?";
        List list = getHibernateTemplate().find(hql,Integer.valueOf(userId));
        return (SysUserEntity) list.get(0);
    }
}
